<!DOCTYPE html  HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>管理员管理</title>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        .th{

            font-family: 宋体;
            text-align: center;
        }
        .btn-primary {
            float: left;
            margin-left: 350px;
            margin-right: 115px;
            margin-top: 0px;
        }
        .table-bordered td,.table-bordered th{
            border:2px solid #5bc0de!important
        }

    </style>

</head>
<body>

<!--弹出框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加管理员
                </h4>
            </div>
            <div class="modal-body">

                <!--设计一个表单，让用户添写信息，并提交到服务器-->
                <form action="saveAdminAdd.php" method="post" class="form-horizontal" enctype="multipart/form-data">
                    <!--管理员名-->
                    <div class="form-group">
                        <label for="aname" class="col-sm-2 control-label">管理员名</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" name="aname" id="aname" placeholder="">
                        </div>
                    </div>
                    <!--密码 -->
                    <div class="form-group">
                        <label for="password" class="col-sm-2 control-label">密码</label>
                        <div class="col-sm-7">
                            <input type="password" required="true" class="form-control" name="password" id="password" placeholder="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="apassword" class="col-sm-2 control-label">确认密码</label>
                        <div class="col-sm-7">
                            <input type="password" required="true" class="form-control" name="apassword" id="apassword"  >
                         </input>

                        </div>
                    </div>

                    <!-- 提交-->
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-default">提交</button>
                        </div>
                    </div>

                </form>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<div class="container">
    <h3 class="title1">后台用户管理</h3>
    <div class="page-header"></div>

        <p>
        <div class="row">
            <button class=" glyphicon glyphicon-plus btn btn-primary" data-toggle="modal" data-target="#myModal">添加
            </button>
        </div>
        </p>



    <table class="table table-bordered">
        <thead>
        <tr>
            <th class="th">管理员编号</th>
            <th class="th">管理员用户名</th>
            <th class="th">操作</th>
        </tr>
        </thead>

        <tbody>
        <?php
        $pagesize = 6;//每页多少条记录
        $pageindex=0;//表示第几页ps:第一页为0.第二页为1

        if (!empty($_GET["pageindex"]))
        {
            $pageindex=$_GET["pageindex"];
        }
        $offset=$pagesize*$pageindex;
        $con = mysqli_connect("localhost","root","","cartoon");
        if(!$con){
            die("数据库连接错误");
        }
        mysqli_query($con,'set names utf8');
        //执行sql命令
        $countSql="select count(*) from admin";
        $countRes=mysqli_query($con,$countSql);

        $row=mysqli_fetch_array($countRes);
        $count=$row[0];

        $query = "select * from admin limit $offset,$pagesize";
        $res = mysqli_query($con,$query);
        //判断查询是否成功
        if($res) // 如果查询失败
        {
            while($row = mysqli_fetch_array($res))
            {
                ?>
                <tr>
                    <td class="th"><?php echo $row["id"] ?></td>
                    <td class="th"><?php echo $row["adminName"] ?></td>
                    <td class="th">
                        <a href="adminEdit.php?id=<?php echo $row['id'] ?>" class="btn btn-sm btn-info">修改</a>
                        <a href="adminDelete.php?id=<?php echo  $row['id'] ?>" onClick="return confirm('确定删除?');"class="btn btn-danger btn-sm">删除</a>
                    </td>
                </tr>
            <?php    }
        }
        ?>
        </tbody>
    </table>
    <nav>
        <ul class="pager">
            <li><a href="aList.php?pageindex=<?php echo $pageindex-1 <0 ? 0 :$pageindex-1 ?>">上一页</a></li>
            <li>共有<?php echo $count?>条记录，<?php echo ceil($count/$pagesize)?>页</li>
            <li><a href="aList.php?pageindex=<?php echo  $pageindex+1>=ceil($count/$pagesize) ? ceil($count/$pagesize)-1 : $pageindex+1 ?>">下一页</a></li>
        </ul>
    </nav>
</div>
</body>
</html>